home *** CD-ROM | disk | FTP | other *** search
/ Chip 2003 November / Chip_2003-11_cd1.bin / program / delphi / kompon / BalmsoftPolyglot.exe / {app} / Demos / Delphi 4 / bsPolyglotDemoFrm.pas < prev    next >
Pascal/Delphi Source File  |  2003-08-07  |  2KB  |  93 lines

  1. unit bsPolyglotDemoFrm;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils,
  7.   {$IFDEF D6_OR_HIGHER}
  8.   Variants,
  9.   {$ENDIF}
  10.   Classes, Graphics, Controls, Forms,
  11.   Dialogs, StdCtrls, ExtCtrls, TypInfo, DB, Grids,
  12.   DBGrids, bsPolyglotUn, DBTables;
  13.  
  14. type
  15.   TbsPolyglotDemoForm = class(TForm)
  16.     cbLanguages: TComboBox;
  17.     Label1: TLabel;
  18.     Memo1: TMemo;
  19.     Label2: TLabel;
  20.     Button1: TButton;
  21.     Panel1: TPanel;
  22.     DataSource1: TDataSource;
  23.     ComboBox1: TComboBox;
  24.     Label3: TLabel;
  25.     RadioGroup1: TRadioGroup;
  26.     Button2: TButton;
  27.     Panel2: TPanel;
  28.     DBGrid1: TDBGrid;
  29.     bsPolyglotTranslator1: TbsPolyglotTranslator;
  30.     PolyglotManager: TbsPolyglotManager;
  31.     Label4: TLabel;
  32.     Table1: TTable;
  33.     procedure FormCreate(Sender: TObject);
  34.     procedure cbLanguagesChange(Sender: TObject);
  35.     procedure Button1Click(Sender: TObject);
  36.     procedure Button2Click(Sender: TObject);
  37.   private
  38.     procedure FillLanguages;
  39.   public
  40.     { Public declarations }
  41.   end;
  42.  
  43. var
  44.   bsPolyglotDemoForm: TbsPolyglotDemoForm;
  45.  
  46. implementation
  47.  
  48. {$R *.dfm}
  49.  
  50. resourcestring
  51.   strYouSelected = 'You Selected: ';
  52.   strMessage1 = 'Message1';
  53.  
  54. procedure TbsPolyglotDemoForm.FillLanguages;
  55. var
  56.   lPolyglot: TbsCorePolyglot;
  57.   i: Integer;
  58. begin
  59.   // same dir as exe file
  60.   PolyglotManager.LangsDir := ExtractFileDir(ParamStr(0));
  61.   cbLanguages.Items.Clear;
  62.   lPolyglot := TbsCorePolyglot.GetCorePolyglot;
  63.   for i := 0 to lPolyglot.LangCount - 1 do
  64.   begin
  65.     cbLanguages.Items.Add(lPolyglot.Langs[i]);
  66.     if lPolyglot.Langs[i] = lPolyglot.CurrentLang then
  67.       cbLanguages.ItemIndex := i;
  68.   end;
  69. end;
  70.  
  71. procedure TbsPolyglotDemoForm.FormCreate(Sender: TObject);
  72. begin
  73.   FillLanguages;
  74. end;
  75.  
  76. procedure TbsPolyglotDemoForm.cbLanguagesChange(Sender: TObject);
  77. begin
  78.   PolyglotManager.CurrentLang := cbLanguages.Text;
  79.   FillLanguages;
  80. end;
  81.  
  82. procedure TbsPolyglotDemoForm.Button1Click(Sender: TObject);
  83. begin
  84.   MessageDlg(strMessage1, mtInformation, [mbOk], 0);
  85. end;
  86.  
  87. procedure TbsPolyglotDemoForm.Button2Click(Sender: TObject);
  88. begin
  89.   MessageDlg(strYouSelected + RadioGroup1.Items.Strings[RadioGroup1.ItemIndex], mtInformation, [mbOk], 0);
  90. end;
  91.  
  92. end.
  93.